﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Neat.Mathematics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Neat;

namespace Kinectoid
{
    public enum BlockTypes
    {
        None= 0,
        Solid = -1,
        Red = -2,
        Green = -3,
        Blue = -4,
        Yellow = -5,
        Pink = -6
    }

    public enum Items
    {
        None = 0
    }

    public class Block
    {
        public BlockTypes BlockType = BlockTypes.Solid;
        public Polygon Mesh;
        public Vector2 Size = new Vector2(100, 24);
        public Items Item = Items.None;
        public NeatGame Game;
        public bool Dead = false;
        public int Score = 20;

        public Block(NeatGame game, Vector2 Position)
        {
            Game = game;
            Mesh = Polygon.BuildRectangle(Position.X, Position.Y, Size.X, Size.Y);
            Mesh.AutoTriangulate = true;
            Mesh.Triangulate();
        }

        public virtual void Behave(GameTime gameTime)
        {
        }

        public virtual void Hit()
        {
            Dead = true;
        }

        public virtual void Render(SpriteBatch spriteBatch, Vector2 offset)
        {
            Color tint = Color.White;
            string texture = "solid";
            if (BlockType < 0)
            {
                if (BlockType == BlockTypes.Blue) tint = Color.Blue;
                else if (BlockType == BlockTypes.Red) tint = Color.Red;
                else if (BlockType == BlockTypes.Green) tint = Color.Green;
                else if (BlockType == BlockTypes.Yellow) tint = Color.Yellow;
                else if (BlockType == BlockTypes.Pink) tint = Color.Pink;
            }

            spriteBatch.Draw(Game.GetTexture(texture), GeometryHelper.Vectors2Rectangle(Mesh.GetPosition() + offset,Size), tint);
        }
    }
}
